package com.atguigu.tingshu.search.receiver;

import com.alibaba.nacos.api.remote.request.PushAckRequest;
import com.atguigu.tingshu.common.constant.KafkaConstant;
import com.atguigu.tingshu.search.service.SearchService;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @author Wu Xingbin
 * @date 2023/11/21/18:27
 */
@Slf4j
@Component
public class SearchReceiver {

    @Autowired
    private SearchService searchService;


    @KafkaListener(topics = KafkaConstant.QUEUE_ALBUM_UPPER)
    public void upperGoods(ConsumerRecord<String, String> consumerRecord) {
        //上传专辑
        Long l = Long.parseLong(consumerRecord.value());
        if (null != l) {
            searchService.upperAlbum(l);
        }
    }

    @KafkaListener(topics = KafkaConstant.QUEUE_ALBUM_LOWER)
    public void lowerGoods(ConsumerRecord<String, String> consumerRecord) {
        //下线专辑
        Long l = Long.parseLong(consumerRecord.value());
        if (null != l) {
            searchService.lowerAlbum(l);
        }
    }
}
